pub fn compute_largest() {
    let number_list = vec![1, 5, 7, 456, 13, 45];
    let mut largest = invoke_func(&number_list);

    println!("{}", largest);


    let number_list = vec![12, 456, 74, 1123, 4754];
    let mut largest = invoke_func(&number_list);

    println!("{}", largest);
}

fn invoke_func(list: &[i32]) -> i32 {
    let mut largest = list[0];
    for &number in list {
        if number > largest {
            largest = number;
        }
    }
    largest
}

pub fn compute_largest_one() {
    let number_list = vec![1, 5, 7, 456, 13, 45];
    let mut largest = invoke_func_one(&number_list);

    println!("{}", largest);


    let char_list = vec!['a', 'v', 'c', 'd'];
    let result = invoke_func_one(&char_list);

    println!("{}", result);
}

fn invoke_func_one<T: PartialOrd + Copy>(list: &[T]) -> T {
    let mut largest = list[0];
    for &number in list {
        if number > largest {
            largest = number;
        }
    }
    largest
}

pub fn compute_largest_two() {
    let number_list = vec![1, 5, 7, 456, 13, 45];
    let mut largest = invoke_func_two(&number_list);

    println!("{}", largest);


    let char_list = vec!["hello", "word"];
    let result = invoke_func_two(&char_list);

    println!("{}", result);
}

// fn invoke_func_two<T: PartialOrd + Copy>(list:&[T]) -> T {
//    let mut largest = list[0];
//    for &number in list.iter() {
//       if number > largest {
//          largest = number;
//       }
//    }
//    largest
// }
fn invoke_func_two<T: PartialOrd + Clone>(list: &[T]) -> &T {
    let mut largest = &list[0];
    for number in list.iter() {
        if number > &largest {
            largest = number;
        }
    }
    largest
}